{extend name="common/layout" /}
{block name="main"}
<div class="admin-main fadeInUp animated" ng-app="hd" ng-controller="ctrl">

    <div class="padding30">
        <h3 class="page-box-title">{$title}</h3>
    </div>
    <div class="layui-form-box">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">{:lang('Group Name')}</label>
                <div class="layui-input-6">
                    <input type="text" name="title" ng-model="field.title" lay-verify="required" placeholder="{:lang('Please enter the user group name')}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">{:lang('Discount')}</label>
                <div class="layui-input-6">
                    <input type="text" name="discount" ng-model="field.discount" lay-verify="required" placeholder="{:lang('Please input 10-100')}" class="layui-input">
                </div>
            </div>
        </br></br>
            <div class="layui-form-item">
                 <label class="layui-form-label layui-form-label-no"></label>
                 <div class="layui-input-6 pleft22">
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('Submit')}</button>
    <!--                 <a href="{:url('admingroup')}" class="layui-btn layui-btn-primary">{:lang('Back')}</a>
     -->            </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="footer"}
<script>
    var m = angular.module('hd',[]);
    m.controller('ctrl',['$scope',function($scope) {
        $scope.field = '{$info}'!='null'?{$info}:{title:'',discount:10};
        layui.use(['form', 'layer'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery;
            form.on('submit(submit)', function (data) {
                loading = layer.load(1,{shade:[0.1,'#fff']});
                // 提交到方法 默认为本身
                data.field.group_id = $scope.field.group_id;
                $.post("", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                            location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            })
        });
    }]);
</script>
{/block}